<?php

class Articles extends Db
{
    private $_table = 'articles';
    public function select($params) {
        $sql = "SELECT * FROM {$this->_table} ";
        
        if (!empty($params['offset'])) {
            $offset = ($params['offset'] - 1)*PER_PAGE;
            $sql .= 'LIMIT '.$offset.', '.PER_PAGE;
        }
        $articles = $this->query($sql);
        return $articles;
    }
    public function count(){
        $sql = 'SELECT COUNT(*) AS COUNT FROM articles';
        $data = $this->query($sql);
        if (!empty($data[0]['COUNT'])) return (int)$data[0]['COUNT'];
        return 0;
    }
}
